package cn.edu.neu.softlab633.influencemaximization.sy.Index;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Jason on 2017/5/7.
 */
public class TopicIndex {

    public static Map getTopicIndex(String filepath) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(filepath));
        Map<Long, Double[]> index = new HashMap<>();
        String line = br.readLine();
        while (line != null) {
            long id = Long.valueOf(line.split(",")[0]);
            String[] tmp = line.split(",")[1].split(" ");
            Double[] topic = new Double[tmp.length];
            for (int i = 0; i < tmp.length; i++) {
                topic[i] = Double.valueOf(tmp[i]);
            }
            index.put(id, topic);
            line = br.readLine();
        }
        br.close();
        return index;
    }
}
